package com.edais.dao;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.edais.domain.GetUserInfo;
import com.edais.domain.IcoUserFuncInfo;
import com.edais.domain.MobileValidate;
import com.edais.domain.NoticeInfo;
import com.edais.domain.User;
import com.edais.domain.UserAccountDetail;
import com.edais.domain.UserInfo;
import com.edais.persistence.UserMapper;

@Repository

public class UserDao {
	@Autowired
	private UserMapper userMapper;

	public List<GetUserInfo> loginCheck(String mobile, String password, String type) throws Exception{
		return userMapper.loginCheck(mobile, password, type);
	}

	public void addUser(User user) throws Exception{
		userMapper.addUser(user);
	}

	public void addUserInfo(UserInfo userInfo) throws Exception {
		userMapper.addUserInfo(userInfo);
	}

	public void resetPsw(String mobile, String newPsw, String type) throws Exception {
		userMapper.resetPsw(mobile, newPsw, type);
	}

	public void resetPswCash(String mobile, String newPsw, String type) throws Exception {
		userMapper.resetPswCash(mobile, newPsw, type);
	}
	
	public User getUserByParm(Map<String, Object> map) throws Exception{
		return userMapper.getUserByParm(map);
	}


	public User getUserDetail(String userID) throws Exception{
		return userMapper.getUserDetail(userID);
	}

	public UserAccountDetail getUserAccountDetail(String userID) throws Exception{
		return userMapper.getUserAccountDetail(userID);
	}

	public void resetPswById(String newPsw, String userID, String oldPsw) throws Exception{
		userMapper.resetPswById(newPsw, userID,oldPsw);
	}
	
	public UserInfo getUserInfo(String userId) throws Exception{
		return userMapper.getUserInfo(userId);
	}
	
	public void saveRandomCode(MobileValidate mobileValidate) throws Exception{
		userMapper.saveRandomCode(mobileValidate);
	}
	public Integer getChannelId(String channelName) throws Exception{
		return userMapper.getChannelId(channelName);
	}
	
	public Map<String, Object> getChannelInfo(String channelName) throws Exception{
		return userMapper.getChannelInfo(channelName);
	}

	public void updateToBeLender(String allowLend, String userId) throws Exception{
		userMapper.updateToBeLender(allowLend,userId);
	}
	public String getUserNickNameSeqNextVal() throws Exception{
		return userMapper.getUserNickNameSeqNextVal();
	}
	public int getUserNotMeByInviteCode(String invitationCode, String id) throws Exception{
		return userMapper.getUserNotMeByInviteCode(invitationCode,id);
	}
	public int getInviteCodeCount(String invitationCode) throws Exception{
		return userMapper.getInviteCodeCount(invitationCode);
	}
	public void updateInvitationCode(String invitationCode, String userId) throws Exception{
		userMapper.updateInvitationCode(invitationCode, userId);
	}
	public void updateLastLoginTime(String userId,String ip) throws Exception{
		userMapper.updateLastLoginTime(userId,ip);
	}
	
	public User getInviterInfo(String invitationCode) throws Exception{
		return userMapper.getInviterInfo(invitationCode);
	}
	
	/** 获取系统参数配置 */
	public String getSystemSettingValue(String key) throws Exception {
		return userMapper.getSystemSettingValue(key);
	}
	
	/** 根据特定的name得到参数表中对应的协议编号 */
	public List<Map<String, String>>  getSysSettByAgreementNo() throws Exception {
		return userMapper.getSysSettByAgreementNo();
	}
	
	/**
	 * 更改头像
	 * */
	public void modifySculpture(Map<String, Object> map) throws Exception{
		userMapper.modifySculpture(map);
	}
	
	public int checkIdCardIsExist(Map<String, Object> map) throws Exception{
		return userMapper.checkIdCardIsExist(map);
	}
	
	public int updSinaIdcardValidate(Map<String, Object> map) throws Exception{
		return userMapper.updSinaIdcardValidate(map);
	}
	/**
	 * 调用存储过程获取邀请码
	 * @param map
	 * @throws Exception
	 */
	public void getInvitationCode(Map<String, Object> map) throws Exception{
		userMapper.getInvitationCode(map);
	}
	
	//更新用户信息
	public void updUser(Map<String, Object> map) throws Exception{
		userMapper.updUser(map);
	}
	public void updUserInfo(Map<String, Object> map) throws Exception{
		userMapper.updUserInfo(map);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	//手机是否存在检查 
	public int phoneIsExisted(String mobile) throws Exception{
		return userMapper.phoneIsExisted(mobile);
	}
	
	//查询短信发送记录表
	public Map querySendMesRec(Map<String, Object> map) throws Exception{
		return userMapper.querySendMesRec(map);
	}
	
	//获取短信模版
	public Map queryTemplate(Map<String, Object> map) throws Exception{
		return userMapper.queryTemplate(map);
	}
	
	//添加短信发送记录表
	public void addSendMsgRec(Map<String, Object> map) throws Exception{
		userMapper.addSendMsgRec(map);
	}
	
	//短信标志设为无效
	public void setInvalidFlag(Map<String, Object> map) throws Exception{
		userMapper.setInvalidFlag(map);
	}
	
	// 获取数据库时间
	public Date querySysDate() throws Exception{
		return userMapper.querySysDate();
	}
	
	//连连实名认证后更新用户订单信息
	public void updateUserInfoAfterLLPayAuth(User user ){
		userMapper.updateUserInfoAfterLLPayAuth(user);
	}
	
	//连连实名认证后更新user_info表信息
	public void updateUserIdCardAfterLLPayAuth(UserInfo userInfo){
		userMapper.updateUserIdCardAfterLLPayAuth(userInfo);
	}
	
	//创建主账户后更新is_create_acct字段
	public void updateUserIsCreateAcctAfterLLPayAuth(User user ){
		userMapper.updateUserIsCreateAcctAfterLLPayAuth(user);
	}
	/***
	 * 删除微信userid绑定关系
	 * @param userId
	 * @return
	 * @throws Exception
	 */
	public int deleteWeixinBingding(String userId) {
		// TODO Auto-generated method stub
		return userMapper.deleteWeixinBingding(userId);
	}
	/***
	 * 查询该手机号的密码
	 * @param querMap
	 * @return
	 */
	public String queryPassword(Map<String, Object> querMap) {
		// TODO Auto-generated method stub
		return userMapper.queryPassword(querMap);
	}
	
	/***
	 * 根据userId查询用户密码
	 * @param map
	 * @return
	 */
	public String getPWDByUserId(Map<String, String> map) {
		// TODO Auto-generated method stub
		return userMapper.getPWDByUserId(map);
	}
	
	/**
	 * 根据身份证号和手机号查询是否存在信息
	 * @param map
	 * @return
	 */
	public UserInfo queryUserInfoByIDCardAndMobile(Map<String, Object> map){
		return userMapper.queryUserInfoByIDCardAndMobile(map); 
	}
	/**
	 * 查询该手机号的密码
	 * @param map
	 * @return
	 */
	public String getUserPassword(String userName) {
		// TODO Auto-generated method stub
		return userMapper.getUserPassword(userName);
	}

	/***
	 * 查询密码输入错误剩余次数 
	 * @param userName
	 * @return
	 */
	public int getLoginErrorTime(String userName) {
		// TODO Auto-generated method stub
		return userMapper.getLoginErrorTime(userName);
	}

	/**
	 * 修改该用户密码输入错误次数
	 * @param userName
	 */
	public void updateLoginErrorTime(String userName) {
		// TODO Auto-generated method stub
		userMapper.updateLoginErrorTime(userName);
	}

	/**
	 * 恢复该用户密码输入次数超限
	 * @param userName
	 */
	public void updateLoginErrorTimeBack(String userName) {
		// TODO Auto-generated method stub
		userMapper.updateLoginErrorTimeBack(userName);
	}

	/**
	 * 恢复该用户短信验证码使用次数
	 * @param userName
	 */
	public void updateJudgeCaptchaTime(Map<String, Object> querMap) {
		// TODO Auto-generated method stub
		userMapper.updateJudgeCaptchaTime(querMap);
	}
	
	/**
	 * 增加该用户当日发送短信次数
	 * @param userName
	 */
	public void addJudgeCaptchaTime(Map<String, Object> querMap) {
		// TODO Auto-generated method stub
		userMapper.addJudgeCaptchaTime(querMap);
	}
	

	/**
	 * 查询总菜单功能定制表数据
	 * @param userId
	 * @return
	 */
	public List<IcoUserFuncInfo> getAllIcoFuncList() {
		// TODO Auto-generated method stub
		return userMapper.getAllIcoFuncList();
	}

	/**
	 * 查询个人菜单功能定制表数据
	 * @param requestMap
	 * @return
	 */
	public List<IcoUserFuncInfo> getUserIcoFuncList(String userId) {
		// TODO Auto-generated method stub
		return userMapper.getUserIcoFuncList(userId);
	}

	/**
	 * 发布个人菜单功能定制表数据
	 * @param userId
	 * @param icoFuncId
	 */
	public void addUserIcoFuncList(Map<String, String> requestMap) {
		// TODO Auto-generated method stub
		userMapper.addUserIcoFuncList(requestMap);
	}

	
	/**
	 * 删除个人菜单功能定制表数据
	 * @param userid
	 */
	public void deleteUserIcoFuncSort(String userid){
		userMapper.deleteUserIcoFuncSort(userid);
	}
	
	/**
	 *通过参数查询总菜单功能定制表数据
	 * @param userId
	 * @return
	 */
	public List<IcoUserFuncInfo> getAllIcoFuncListByParams(String userId){
		return userMapper.getAllIcoFuncListByParams(userId);
	}

	public String getSysSettingHtmlInfo(String name)throws Exception{
		// TODO Auto-generated method stub
		return userMapper.getSysSettingHtmlInfo(name);
	}
	
	/**
	 * 手机是否存在检查 
	 * 
	 * @return int
	 */
	public int checkIsGiveWelfare(Map<String, Object> map){
		return userMapper.checkIsGiveWelfare(map);
	}

	/**
	 * app滚动公告信息取信息system_setting(新的方式)
	 */
	public NoticeInfo getSystemSettingInfoNew(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return userMapper.getSystemSettingInfoNew(map);
	}

	/**
	 *通过参数查询总菜单功能定制表数据（微信）
	 * @param userId
	 * @return
	 */
	public List<IcoUserFuncInfo> getAllIcoFuncListForwx(String userId) {
		// TODO Auto-generated method stub
		return userMapper.getAllIcoFuncListForwx(userId);
	}
	/**
	 * 取得菜单功能定制表数据（更多）
	 * @param
	 * @return
	 */
	public IcoUserFuncInfo getIcoFuncGd() {
		// TODO Auto-generated method stub
		return userMapper.getIcoFuncGd();
	}

	/**
	 * 查询总菜单功能定制表数据（微信）
	 * @param
	 * @return
	 */
	public List<IcoUserFuncInfo> getAllIcoFuncListWx() {
		// TODO Auto-generated method stub
		return userMapper.getAllIcoFuncListWx();
	}

	/**
	 * 根据参数查询总菜单功能定制表数据（老版本）
	 * @param
	 * @return
	 */
	public List<IcoUserFuncInfo> getAllIcoFuncListOld(String userId) {
		// TODO Auto-generated method stub
		return userMapper.getAllIcoFuncListOld(userId);
	}

	/**
	 * 查询默认总菜单功能定制表数据（老版本）
	 * @param
	 * @return
	 */
	public List<IcoUserFuncInfo> getAllIcoFuncListDefaultOld() {
		// TODO Auto-generated method stub
		return userMapper.getAllIcoFuncListDefaultOld();
	}

	/**
	 * 获取数据库系统时间
	 * @return
	 * @throws Exception
	 */
	public Date getSysdate(){
		return userMapper.getSysdate();
	}

	/**
	 * 查询快捷菜单项
	 * @param id
	 * @return
	 */
	public IcoUserFuncInfo queryIcoFuncInfo(Long id){
		return userMapper.queryIcoFuncInfo(id);
	}

}
